package tasks

import (
	"gitee.com/lllgo/gopkg/tasks"
	"gitee.com/lllgo/opsctl/pkg/cmd"
	"gitee.com/lllgo/opsctl/pkg/conf"
	"github.com/mitchellh/mapstructure"
)

func init() {
	cmd.RegisterCmdPlugin("tasks", func(pc conf.PluginConfig, c conf.ComponentConfig) error {
		var cfg tasks.DispatcherConfig
		if err := mapstructure.Decode(c, &cfg); err != nil {
			return err
		}

		return cfg.DispatchTask()
	}, conf.PluginConfig{
		Desc:     "多命令任务编排，支持同步任务和并发任务协调",
		Cmd:      "tasks",
		Register: "register.yaml",
	})

}
